Skip to main content

null

null is a primitive type meaning 'non-existent'.

Its responsibility is to represent the intentional absence of any object value.

null, unlike undefined, is not an identifier for a property of the global object.

  • Instead, null expresses a lack of identification.

The other way to think about null is that a null variable points to no object.

Let's view an example, specifically initialization:

 

caution

While == differs from === (equality vs identity), only identity (===) is allowed.

In the following example we use === to learn about null.

 

 

tip

Overall, be aware of null and learn where they can show up. Use try...catch blocks to handle them.

It's also good to understand the differences between null, undefined, and NaN.